package com.seecen;

import com.seecen.entity.Dept;
import com.seecen.mapper.DeptMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

public class App3Lock {
    public static void main(String[] args) throws InterruptedException {
        InputStream is = App3Lock.class.getClassLoader().getResourceAsStream("mybatis.xml");
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);
        SqlSession session = factory.openSession();

        DeptMapper deptMapper = session.getMapper(DeptMapper.class);
        List<Dept> list = deptMapper.findByLock();
        list.forEach(System.out::println);
        Thread.sleep(20 * 1000);
        session.commit();
        session.close();
    }
}
